package com.example.myapplication;

import static com.example.myapplication.R.*;

import android.content.Context;
import android.os.Bundle;
import androidx.recyclerview.widget.RecyclerView;



import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;


public class adapterActivity extends AppCompatActivity {

    private RecyclerView recyclerView;
    private Context context;
    private adapter adapter;

    List<Map<String,Object>> list1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_adapter);

        Context context=this;

        recyclerView=findViewById(R.id.recycleView);

        int[] phonename={R.drawable.p_1, R.drawable.p_2, R.drawable.p_3};
        String[]price={"1000","2000","3000"};
        String[]config={"ssss","qqqq","rrrr"};
        list1=new ArrayList<Map<String, Object>>();
        for(int i=0;i<phonename.length;i++){
            Map<String, Object> map=new HashMap<>();
            map.put("name",phonename[i]);
            map.put("price",price[i]);
            map.put("config",config[i]);
            list1.add(map);
        }
       /*
        list=new ArrayList<String>();
        for(int i=0;i<9;i++){
            list.add("这是第"+i+"个例子!");
        }*/
        adapter adapter0=new adapter(context,list1);
        recyclerView.setAdapter(adapter0);

        LinearLayoutManager manager = new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.VERTICAL);

        recyclerView.setLayoutManager(manager);

    }
}